package xyz.wanhongtao.smtpclient.controller;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.wanhongtao.smtpclient.object.form.SendMailForm;
import xyz.wanhongtao.smtpclient.object.vo.Result;
import xyz.wanhongtao.smtpclient.object.vo.SendMailRes;
import xyz.wanhongtao.smtpclient.service.SmtpService;

/**
 * @author wanghongtao <wanghongtao05@kuaishou.com>
 * Created on 2023-07-03
 */
@AllArgsConstructor
@RequestMapping("/api")
@RestController
public class SmtpController {
    private final SmtpService smtpService;

    /**
     * 发送邮件
     * @param sendMailForm 发送着，接受者，发送信息
     * @return 结果
     */
    @PostMapping("/send")
    public Result<SendMailRes> sendMail(SendMailForm sendMailForm) {
        return Result.success(smtpService.sendMessage(sendMailForm));
    }
}
